#ifndef NOTIFY_ICON_HEADER
#define NOTIFY_ICON_HEADER

class CTrayIcon
{
	NOTIFYICONDATA	nid_;
public:
	CTrayIcon()
	{
		ZeroMemory( &nid_, sizeof(nid_) );
	}

	BOOL SetIcon(HICON hIcon)
	{
		nid_.hIcon = hIcon;
		nid_.uFlags = NIF_ICON;
		return Shell_NotifyIcon( NIM_MODIFY, &nid_ );
	}

	BOOL SetTip(LPCTSTR lpstrMsg)
	{
		nid_.uFlags = NIF_TIP;
		lstrcpyn( nid_.szTip, lpstrMsg, sizeof(nid_.szTip)/sizeof(nid_.szTip[0]) );
		return Shell_NotifyIcon( NIM_MODIFY, &nid_ );
	}

	BOOL ShowTrayIcon()
	{
		return Shell_NotifyIcon( NIM_ADD, &nid_ );
	}

	BOOL HideTrayIcon()
	{
		return Shell_NotifyIcon( NIM_DELETE, &nid_ );
	}

	BOOL Create(HWND hWnd, UINT ID, HICON hIcon, UINT uCBMsg, LPCTSTR lpstrMsg)
	{
		nid_.cbSize = sizeof(nid_);
		nid_.hWnd = hWnd;
		nid_.uID = ID;
		nid_.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP;
		nid_.uCallbackMessage = uCBMsg;
		nid_.hIcon = hIcon;
		lstrcpyn( nid_.szTip, lpstrMsg, sizeof(nid_.szTip)/sizeof(nid_.szTip[0]) );
		return TRUE;
	}

	~CTrayIcon()
	{
        HideTrayIcon();
	}
};

#endif